package com.ruoyi.web.controller.iot;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.iot.service.IotQueryService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/iotdb")
public class IotDbController extends BaseController {

    private final IotQueryService iotQueryService;

    public IotDbController(IotQueryService iotQueryService) {
        this.iotQueryService = iotQueryService;
    }

    @PostMapping("/query")
    public AjaxResult query(@Validated @RequestBody IotQueryRequest request) {
        return AjaxResult.success(iotQueryService.executeQuery(request.getSql()));
    }

    @GetMapping("test")
    public AjaxResult test() {
        return AjaxResult.success("你好，世界");
    }
}
